package view.component.button
{
	import flash.events.Event;
	import flash.text.TextField;
	
	import framework.utils.TextUtil;
	import framework.view.components.button.ButtonProxy;
	
	public class LabelChangeButtonProxy extends ButtonProxy
	{
		public function LabelChangeButtonProxy()
		{
			super();
		}
		
		protected var textStr:String = "";
		
		override public function set text(value:String):void
		{
			if(textStr == "")
			{
				textStr = value;
			}
			
			label = skin.getChildByName("label") as TextField;
			if (label)
			{
				if (label.embedFonts)
				{
					TextUtil.setText(label, value, font);
				}
				else
				{
					label.text = value;
				}
			}
		}
		
		override public function get text():String
		{
			return textStr;
		}
		
		override protected function mouseDownHandler(event:Event):void
		{
			super.mouseDownHandler(event);
			text = textStr;
		}
		
		override protected function mouseOutHandler(event:Event):void
		{
			super.mouseOutHandler(event);
			text = textStr;
		}
		
		override protected function mouseOverHandler(event:Event):void
		{
			super.mouseOverHandler(event);
			text = textStr;
		}
		
		override protected function mouseUpHandler(event:Event):void
		{
			super.mouseUpHandler(event);
			text = textStr;
		}
		
		override public function set enabled(value:Boolean):void
		{
			super.enabled = value;
			text = textStr;
		}
	}
}